package tv.geir.slackspace.analyzer;

import java.util.HashSet;
import java.util.Set;

/**
 * Utility methods for class name analyzing
 * 
 * @author Geir Gullestad Pettersen
 *
 */
public class ClassNameUtils {

	public Set<String> getClassNamesFromSignature( String signature ) {
		HashSet<String> classnames = new HashSet<String>();
		for( int a=signature.indexOf('L') +1, b=signature.indexOf(';'); a > 0 && b > a; ) {
			
			String classname = signature.substring( a, b ).replace( '/', '.' );
			
			classnames.add(classname);
			a = signature.indexOf('L', b ) +1;
			b = signature.indexOf( ';', a );
		}
		return classnames;
	}
	
	public String classUrlToQualifiedClassName( String name ) { 
		if( name.indexOf( '/' ) > 0 ) {
			name = name.replace( '/', '.' );
		}
		return name;
	}

}
